// import qs from 'qs'
import { COMMON_METHOD } from '@/constant/common'
import Vue from 'vue'

const moduleName = 'support'

// 附件
export const attachment = Object.assign({}, COMMON_METHOD, {
  serveUrl: '/' + moduleName + '/' + 'attachment' + '/',
  // 上传
  upload() {
    return Vue.prototype.$httpRequest.post(this.serveUrl + 'upload')
  },
  // 下载
  download(id) {
    return Vue.prototype.$httpRequest.download(this.serveUrl + id + '/download')
  }
}
)

// 通知公告
export const notice = Object.assign({}, COMMON_METHOD, {
  serveUrl: '/' + moduleName + '/' + 'notice' + '/',
  enable(id) {
    return Vue.prototype.$httpRequest.put(this.serveUrl + id + '/enable')
  },
  disable(id) {
    return Vue.prototype.$httpRequest.put(this.serveUrl + id + '/disable')
  },
  setTop(id) {
    return Vue.prototype.$httpRequest.put(this.serveUrl + id + '/setTop')
  },
  cancelTop(id) {
    return Vue.prototype.$httpRequest.put(this.serveUrl + id + '/cancelTop')
  },

  portlet(params) {
    return Vue.prototype.$httpRequest.get(this.serveUrl + 'portlet', params)
  },
  // 阅读量加1
  updateReadCount(id) {
    return Vue.prototype.$httpRequest.put(this.serveUrl + id + '/updateReadCount', null, false)
  },
  // 浏览列表
  viewList(params) {
    return Vue.prototype.$httpRequest.get(this.serveUrl + 'viewList', params)
  }

}
)

// 组件分类
export const portletCategory = Object.assign({}, COMMON_METHOD, {
  serveUrl: '/' + moduleName + '/' + 'portletCategory' + '/',
  enable(id) {
    return Vue.prototype.$httpRequest.put(this.serveUrl + id + '/enable')
  },
  disable(id) {
    return Vue.prototype.$httpRequest.put(this.serveUrl + id + '/disable')
  },
  getPortletList(params) {
    return Vue.prototype.$httpRequest.get(this.serveUrl + 'portal/list', params)
  }
}
)

// 组件
export const portlet = Object.assign({}, COMMON_METHOD, {
  serveUrl: '/' + moduleName + '/' + 'portlet' + '/',
  enable(id) {
    return Vue.prototype.$httpRequest.put(this.serveUrl + id + '/enable')
  },
  disable(id) {
    return Vue.prototype.$httpRequest.put(this.serveUrl + id + '/disable')
  }
}
)

// 门户模板
export const portalTemplate = Object.assign({}, COMMON_METHOD, {
  serveUrl: '/' + moduleName + '/' + 'portalTemplate' + '/',
  enable(id) {
    return Vue.prototype.$httpRequest.put(this.serveUrl + id + '/enable')
  },
  disable(id) {
    return Vue.prototype.$httpRequest.put(this.serveUrl + id + '/disable')
  }
}
)

// 流水号
export const serialNo = Object.assign({}, COMMON_METHOD, {
  serveUrl: '/' + moduleName + '/' + 'serialNo' + '/'
}
)

// 高级查询方案
export const advanceQueryScheme = Object.assign({}, COMMON_METHOD, {
  serveUrl: '/' + moduleName + '/' + 'advanceQueryScheme' + '/'
}
)

// 内置消息
export const message = Object.assign({}, COMMON_METHOD, {
  serveUrl: '/' + moduleName + '/' + 'message' + '/',
  getUnreadMessageCount() {
    return Vue.prototype.$httpRequest.get(this.serveUrl + 'getUnreadMessageCount')
  },
  read(id) {
    return Vue.prototype.$httpRequest.put(this.serveUrl + id + '/read', null, false)
  },
  allRead() {
    return Vue.prototype.$httpRequest.put(this.serveUrl + 'allRead')
  }
}
)

// 内容模板分类
export const contentTemplateCategory = Object.assign({}, COMMON_METHOD, {
  serveUrl: '/' + moduleName + '/' + 'contentTemplateCategory' + '/',
  tree() {
    return Vue.prototype.$httpRequest.get(this.serveUrl + 'tree')
  }
}
)

// 内容模板
export const contentTemplate = Object.assign({}, COMMON_METHOD, {
  serveUrl: '/' + moduleName + '/' + 'contentTemplate' + '/'

}
)

